﻿using Gargoyle.Roton;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Gargoyle.ZZT
{
    public partial class Game : Roton.Environment
    {
        private ByteString BuildFileList(string extension)
        {
            string[] files;
            List<byte> result = new List<byte>();

            files = Cache.FindFiles(extension);
            if (files.Length > 0)
            {
                ByteString fileBS = files[0];
                result.AddRange((byte[])fileBS);
                for (int i = 1; i < files.Length; i++)
                {
                    fileBS = files[i];
                    result.Add(0x0D);
                    result.AddRange((byte[])fileBS);
                }
            }

            return (ByteString)result.ToArray();
        }

        internal void ShowLoadBoard()
        {
            BuildFileList(Parameters.BoardExtension);
        }

        internal void ShowLoadWorld()
        {
            Display.ShowChoice(SelectionParameter.LoadWorld, 0);
            SetScroll("Load World", BuildFileList(Parameters.WorldExtension));
        }

        internal void ShowRestoreGame()
        {
            BuildFileList(Parameters.SavedGameExtension);
        }

        internal void ShowSaveBoard()
        {
        }

        internal void ShowSaveGame()
        {
        }

        internal void ShowSaveWorld()
        {
        }
    }
}